<!DOCTYPE html>
<html>

<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <script src="/js/jquery/jquery.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyComment.css"/>
    <link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
    <script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
    <link rel="stylesheet" href="../js/plugins/jquery-confirm/css/jquery-confirm.css">
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="../js/comment/css/bootstrap.css">
    <script src="../js/comment/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/comment/js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/comment/js/jquery.comment.js"></script>
    <script type="text/javascript" src="../js/comment/js/bootstrap.min.js"></script>
    <script src="../js/plugins/jrender/jrender.min.js"></script>
    <script>
        $(function () {
            var Params = getParams();
            var userid;//用户id
            $.get('/strategyComment/comments/' + Params.id, function (data) {
                userid=data.user.id;
                $('.getstrategy').renderValues({list: data}, {
                    //星级的拼接显示
                    'getStar': function (item, value) {
                        var starhtml = '';
                        var unStarhtml = '';
                        for (var i = 0; i < value; i++) {
                            starhtml += '<i class="fa fa-star"></i>';
                        }
                        for (i = 0; i < 5 - value; i++) {
                            unStarhtml += '<i class="fa fa-star-o"></i>';
                        }

                        $(item).html(starhtml + unStarhtml);
                    },
                    //攻略的跳转
                    setHref: function (item, value) {
                        $(item).attr("href", $(item).data('href') + value);
                    },
                    //用户的跳转
                    setUserHref: function (item, value) {
                        $(item).attr("href", $(item).data('href') + value);
                    }
                })
                //图片的切割
                var imgUrls = data.imgUrls;
                var split = imgUrls.split(';');
                for (var i = 0; i < split.length-1; i++) {
                    console.log(split[i]);
                    var img="";
                     img += "<li><img src='"+split[i]+"'</li>"
                    $('.comment-img').append(img);
                }
                //查询是否关注
                $.get("/attention/" + userid, function (data) {
                    if (data) {
                        $('#followBtn').html('');
                        $('#followBtn').html('已关注');
                    } else {
                        $('#followBtn').html('');
                        $('#followBtn').html('关注');
                    }
                })
                //关注按钮
                $('#followBtn').click(function () {
                    $.post("/attention/", {userGetId: userid}, function (data) {
                        if (data.data) {//用来区分 登录
                            window.location.reload();
                        }
                    })
                })
            })

        })
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="/index.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>点评详情</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<div class="comment">


    <div class="container getstrategy" render-loop="list">
        <div class="row">
            <div class="col-2 comment-head">
                <a data-href="/friend/profiles.html?id=" render-key="list.user.id" render-fun="setUserHref">
                    <img class="rounded-circle" render-src="list.user.headImgUrl">
                </a>
                <button class="btn" id="followBtn"> 关注</button>

            </div>
            <div class="col">
                <span render-html="list.user.nickName"></span>

                <span class="comment-star" render-key="list.starNum" render-fun="getStar">
                       		 </span>
                <span class="comment-date" render-html="list.createTime"></span>

                <div class="comment-content">
                    <p render-html="list.content"></p>
                </div>
                <ul class="comment-img">

                </ul>

                <div class="comment-link">
                    <a data-href="/strategyCatalogs.html?strategyId=" render-fun="setHref"
                       render-key="list.strategy.id">
                        <img data-src="list.strategy.coverUrl">
                        <span render-html="list.strategy.title"></span>
                        <i class="fa fa-angle-right fa-2x"></i>
                    </a>
                </div>

            </div>
        </div>
    </div>

    <div class="count d-flex justify-content-between box">
        <div class="p-2">评论<span>0</span></div>
        <div class="p-2">赞<span>0</span></div>
    </div>
</div>
<div class="comment-list">
    快来发表你的评论吧


<div class="operation">
    <div class="row">
        <div class="col-lg-5">
            <div class="input-group">
                <form>
                    <div class="d-flex justify-content-between">
                        <input  name="error" class="form-control" placeholder="请输入评论的内容......">
                        <button class="btn btn-default saveByInput" type="button">评论!</button>
                    </div>
                </form>
            </div><!-- /input-group -->
        </div><!-- /.col-lg-6 -->
    </div><!-- /.row -->
</div>


</body>

</html>